// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   drag_img.java

package include.ajax;

import include.nseer_db.nseer_db_backup;
import include.tree_index.Nseer;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

// Referenced classes of package include.ajax:
//			ajax_businessComment, multi_businessComment

public class drag_img extends HttpServlet
{

	ServletContext application;
	HttpSession session;
	nseer_db_backup erp_db;
	Nseer n;

	public drag_img()
	{
		erp_db = null;
		n = new Nseer();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			PrintWriter out = response.getWriter();
			nseer_db_backup db = new nseer_db_backup(dbApplication);
			nseer_db_backup db1 = new nseer_db_backup(dbApplication);
			if (db.conn((String)dbSession.getAttribute("unit_db_name")) && db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String human_ID = (String)dbSession.getAttribute("human_IDD");
				String id = request.getParameter("id");
				String link = request.getParameter("link");
				String drag_text = request.getParameter("drag_text");
				String drag_img_top = request.getParameter("drag_img_top");
				String drag_img_left = request.getParameter("drag_img_left");
				String drag_img_name = request.getParameter("drag_img_name");
				String tree_view_name = request.getParameter("tree_view_name");
				String category = request.getParameter("category");
				String groupName = "erp";
				ajax_businessComment demo = new ajax_businessComment();
				demo.setPath(request);
				multi_businessComment mdemo = new multi_businessComment();
				String sql = (new StringBuilder("select * from ")).append(tree_view_name).append(" where category_id='").append(category).append("' and human_id='").append(human_ID).append("' order by id").toString();
				ResultSet rs1 = db1.executeQuery(sql);
				String firstworkname = "";
				String file_id = "";
				if (rs1.next())
					file_id = rs1.getString("file_id");
				String sql2 = "";
				sql2 = (new StringBuilder("select * from ")).append(tree_view_name).append(" where human_id='").append(human_ID).append("' order by id").toString();
				for (ResultSet rs2 = db1.executeQuery(sql2); rs2.next();)
					if (!rs2.getString("hreflink").equals("") && rs2.getString("file_path").indexOf("config") == -1 && rs2.getString("file_id").indexOf(file_id) == 0)
					{
						firstworkname = (new StringBuilder(String.valueOf(rs2.getString("file_path")))).append(rs2.getString("hreflink")).toString();
						rs2.last();
					}

				String sq = (new StringBuilder("select * from drag_img where img_id='")).append(id).append("' and human_ID='").append(human_ID).append("'").toString();
				ResultSet rs = db.executeQuery(sq);
				if (!rs.next())
				{
					String sq11 = (new StringBuilder("insert into drag_img(drag_img_top,drag_img_left,drag_img_name,drag_text,link,img_id,tree_view_name,category,human_ID,firstworkname)values('")).append(drag_img_top).append("','").append(drag_img_left).append("','").append(drag_img_name).append("','").append(drag_text).append("','").append(link).append("','").append(id).append("','").append(tree_view_name).append("','").append(category).append("','").append(human_ID).append("','").append(firstworkname).append("')").toString();
					db.executeUpdate(sq11);
					if (drag_text.indexOf("--") == -1)
						out.println((new StringBuilder("1,")).append(demo.getLang("erp", drag_text)).toString());
					else
						out.println((new StringBuilder("1,")).append(mdemo.getLang(demo, groupName, drag_text)).toString());
				} else
				if (drag_text.indexOf("--") == -1)
					out.println((new StringBuilder("2,")).append(demo.getLang("erp", drag_text)).toString());
				else
					out.println((new StringBuilder("2,")).append(mdemo.getLang(demo, groupName, drag_text)).toString());
				db1.close();
				db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
